<template>
	<view class="mains">
		<view class="chongzhi">
			<div class="actives">
				<div class="left">
					<div>
						<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
							<h3>{{date}}</h3>
						</picker>
					</div>
					<div style="color: #999999;">
						充值总额 <span class="active">{{sum}}</span>
					</div>
				</div>
				<div class="right">

				</div>
			</div>
		</view>
		<view v-for="item in list " :key="item.id" class="actives">
			<div class="left">
				<div>
					<h3>{{item.true_name}}</h3>
				</div>
				<div style="color: #999999;">
					{{item.create_time}}
				</div>
			</div>
			<div class="right">
				+{{item.pay_amount}}
			</div>
		</view>
		<view class="isOver" v-if="flag">-----没有数据了-----</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.agent_id = uni.getStorageSync('agent_id');
			// console.log(this.agent_id)
			this.name = wx.getStorageSync('nickName');
			this.token = wx.getStorageSync('token');
			//console.log(this.token)
			this.chongzhiList()
		},
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				date: currentDate,
				time: "",
				agent_id: this.agent_id,
				startDate: "2019-7-27",
				endDate: "2020-7-27",
				token: "token",
				page: 1,
				limit: 10,
				sum: '',
				m: 1,
				list: [],
				flag: false,
				month: new Date().getMonth() + 1,
				request:false
			}
		},
		onPullDownRefresh() {
			console.log('下拉刷新了')
			this.pageindex = 1
			this.goods = []
			this.flag = false
			setTimeout(() => {
				this.chongzhiList(() => {
					uni.stopPullDownRefresh()
				})
			}, 1000)
		},
			onReachBottom() {
				if (this.request) {
					this.getmoreNews()
					console.log("触底了222")
				}
			},
		
		methods: {
			onPullDown() {
				uni.startPullDownRefresh()
			},
			changes() {
				console.log("改变日期")
			},
			bindDateChange(e) {
				this.date = e.target.value
				// console.log(e.target.value)
				let str = e.target.value.split('-', [3])
				console.log(str)
				let A = str[1]
				this.month = A
				this.chongzhiList()
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				this.month = month
				// console.log(this.month)
				return `${year}-${month}-${day}`;
			},
			chongzhiList() {
				
				this.$flyio.get('v1.Customer/getAgentCustomerRangeLogList', {
						agent_id: 4,
						page: 1,
						limit: 10,
						m: this.month
					}).then((ret) => {
						console.log(ret)
						this.list = ret.data.dataList
						this.sum = ret.data.sum

					})
					.catch((e) => {

					})
			},
			getmoreNews() {
					this.$flyio.get('v1.Customer/getAgentCustomerRangeLogList', {
							agent_id: 4,
							page: 1,
							limit: 10,
							m: this.month
						}).then((ret) => {
							if (ret.code == 0) {
									
								if (ret.data.data.length > 0) {
									this.page++
									this.newsList = this.list.concat(ret.data.data)
								} else {
									this.request = false
								}
							} else {}
							console.log(ret)
						})
						.catch((e) => {
							
						})
			
				}
			
		},
		mounted() {},
	}
</script>

<style scoped lang="scss">
	.active {
		color: red;
	}

	.mains {
		h3 {
			font-size: 30upx;
		}

		.chongzhi {}
	}

	.actives {
		display: flex;
		justify-content: space-between;
		height: 154upx;
		margin: 0 22upx;

		// background-color: green;
		border-bottom: 2upx solid #D3D3D3;

		.right {
			color: red;
			align-self: center;
		}

		.left {
			font-size: 22upx;

			h3 {
				font-size: 30upx;
			}

			align-self: center;
		}
	}

	.isOver {
		width: 100%;
		height: 50px;
		line-height: 50px;
		text-align: center;
		// background: #fff;
		font-size: 28rpx;
	}
</style>
